package commons.base.excel.event;

import java.util.ArrayList;
import java.util.List;

import commons.base.excel.ExcelManager;
import commons.base.excel.event.ExcelEventParser.SimpleSheetContentsHandler;
import commons.base.excel.example.ExcelModelTemplate.ExcelModel;

public class ExampleEventUserModel {
	
	public static void main(String[] args) throws Throwable{
		t2();
	}
	
	public static void t1()throws Exception{
		long start = System.currentTimeMillis();
		
		final List<List<String>> table = new ArrayList<>();
		new ExcelEventParser("D:/git/commons_base/src/main/resources/ExcelTestModel.xlsx").setHandler(new SimpleSheetContentsHandler(){
			
			private List<String> fields;
			
			@Override
			public void endRow(int rowNum) {
				if(rowNum == 0){
					// 第一行中文描述忽略
				}else if(rowNum == 1){
					// 第二行字段名
					fields = row;
				}else {
					// 数据
					table.add(row);
				}
			}
		}).parse();
		
		long end = System.currentTimeMillis();
		
		System.err.println(table.size());
		System.err.println(end - start);
	}
	
	public static void t2()throws Throwable{
		long start = System.currentTimeMillis();
		
		List<ExcelModel> list = ExcelManager.loadByEventDrive(ExcelModel.class, "ExcelTestModel.xlsx", 2);
//		List<ExcelModel> list = ExcelManager.load(ExcelModel.class, "ExcelTestModel.xlsx", 2);
		
		long end = System.currentTimeMillis();
		
		System.err.println(list.size());
		
		System.err.println(end - start);
	}

}
